/**
 * 项目名：phms3
 * 日期：    2019-11-23 11:35:33
 * Copyright (c) 2015- HTSC-版权所有
 */

package com.joysuch.wwyt.bp.entity;

import cn.zlg.common.springmvc.validate.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.joysuch.wwyt.core.entity.BaseMenuFunction;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.hibernate.annotations.WhereJoinTable;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.LinkedHashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "WWYT_BP_JOB")
@SQLDelete(sql = "update WWYT_BP_JOB set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update WWYT_BP_JOB set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BpJob implements java.io.Serializable {

    // columns START
    // ID
    private java.lang.Long id;
    // 岗位名称
    @NotNull(field = "岗位名称")
    private java.lang.String name;
    // 租户
    private java.lang.Long tenentId;
    // 岗位描述
    private java.lang.String description;
    // 人数
    private java.lang.Integer staffCount;
    // 创建人
    private java.lang.Long createBy;
    // 创建时间
    private java.util.Date createTime;
    // 更新人
    private java.lang.Long updateBy;
    // 更新时间
    private java.util.Date updateTime;
    // 删除标记
    private java.lang.String deleteFlag;
    // 组织机构代码
    private java.lang.String orgCode;
    //报警模板id
    private Long alarmTemplateId;

    private String alarmTemplateName;

    //是否已和人员在岗在位同步数据 默认0 否; 1 是
    private boolean locateSync;
    //不同系统同步唯一标识ID
    private String uniqueId;

    //岗位最小人数
    private String minPeopleNumber;
    //岗位最大人数
    private String maxPeopleNumber;
    //风险分区id
    private Long riskDistrictId;
    @Transient
    private String riskDistrictName;
    //岗位地点
    private String site;

    //显示状态 1显示 44不显示
    private Integer showState;

    // columns END
    @Column(name = "show_state")
    public Integer getShowState() {
        return showState;
    }

    public void setShowState(Integer showState) {
        this.showState = showState;
    }

    @Column(name = "min_people_number")
    public String getMinPeopleNumber() {
        return minPeopleNumber;
    }

    public void setMinPeopleNumber(String minPeopleNumber) {
        this.minPeopleNumber = minPeopleNumber;
    }

    @Column(name = "max_people_number")
    public String getMaxPeopleNumber() {
        return maxPeopleNumber;
    }

    public void setMaxPeopleNumber(String maxPeopleNumber) {
        this.maxPeopleNumber = maxPeopleNumber;
    }

    @Column(name = "risk_district_id")
    public Long getRiskDistrictId() {
        return riskDistrictId;
    }

    public void setRiskDistrictId(Long riskDistrictId) {
        this.riskDistrictId = riskDistrictId;
    }


    public String getRiskDistrictName() {
        return riskDistrictName;
    }

    public void setRiskDistrictName(String riskDistrictName) {
        this.riskDistrictName = riskDistrictName;
    }

    @Column(name = "site")
    public String getSite() {
        return site;
    }

    public void setSite(String site) {
        this.site = site;
    }

    @Column(name = "alarm_template_name")
    public String getAlarmTemplateName() {
        return alarmTemplateName;
    }

    public void setAlarmTemplateName(String alarmTemplateName) {
        this.alarmTemplateName = alarmTemplateName;
    }

    @Column(name = "alarm_template_id")
    public Long getAlarmTemplateId() {
        return alarmTemplateId;
    }

    public void setAlarmTemplateId(Long alarmTemplateId) {
        this.alarmTemplateId = alarmTemplateId;
    }

    public void setId(java.lang.Long value) {
        this.id = value;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "Id", unique = true, nullable = false)
    public java.lang.Long getId() {
        return this.id;
    }

    @Column(name = "NAME", length = 30, nullable = false)
    public java.lang.String getName() {
        return this.name;
    }

    public void setName(java.lang.String value) {
        this.name = value;
    }

    @Column(name = "TENENT_ID")
    public java.lang.Long getTenentId() {
        return this.tenentId;
    }

    public void setTenentId(java.lang.Long value) {
        this.tenentId = value;
    }

    @Column(name = "DESCRIPTION", length = 1000)
    public java.lang.String getDescription() {
        return this.description;
    }

    public void setDescription(java.lang.String value) {
        this.description = value;
    }

    @Column(name = "STAFF_COUNT")
    public java.lang.Integer getStaffCount() {
        return this.staffCount;
    }

    public void setStaffCount(java.lang.Integer value) {
        this.staffCount = value;
    }

    @Column(name = "UNIQUE_ID")
    public String getUniqueId() {
        return uniqueId;
    }

    public void setUniqueId(String uniqueId) {
        this.uniqueId = uniqueId;
    }

    public boolean isLocateSync() {
        return locateSync;
    }

    public void setLocateSync(boolean locateSync) {
        this.locateSync = locateSync;
    }

    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    public java.lang.Long getCreateBy() {
        return this.createBy;
    }

    public void setCreateBy(java.lang.Long value) {
        this.createBy = value;
    }

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    public java.util.Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(java.util.Date value) {
        this.createTime = value;
    }

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    public java.lang.Long getUpdateBy() {
        return this.updateBy;
    }

    public void setUpdateBy(java.lang.Long value) {
        this.updateBy = value;
    }

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    public java.util.Date getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(java.util.Date value) {
        this.updateTime = value;
    }

    @Column(name = "DELETE_FLAG", length = 2)
    public java.lang.String getDeleteFlag() {
        return this.deleteFlag;
    }

    public void setDeleteFlag(java.lang.String value) {
        this.deleteFlag = value;
    }

    @Column(name = "ORG_CODE", length = 100)
    public java.lang.String getOrgCode() {
        return this.orgCode;
    }

    public void setOrgCode(java.lang.String value) {
        this.orgCode = value;
    }

    @JsonIgnore
    private Set<BaseMenuFunction> baseMenuFunctions = new LinkedHashSet<>(0);

    @ManyToMany(fetch = FetchType.LAZY, cascade = {})
    @JoinTable(name = "WWYT_BASE_ROLE_MENU_FUNCTION", joinColumns = @JoinColumn(name = "ROLE_ID"), inverseJoinColumns = @JoinColumn(name = "MENU_ID"))
    @WhereJoinTable(clause = "DELETE_FLAG = '0'")
    @OrderBy("menuOrder asc,id asc")
    public Set<BaseMenuFunction> getBaseMenuFunctions() {
        return this.baseMenuFunctions;
    }

    public void setBaseMenuFunctions(Set<BaseMenuFunction> baseMenuFunctions) {
        this.baseMenuFunctions = baseMenuFunctions;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId()).append("name", getName())
                .append("tenentId", getTenentId()).append("description", getDescription())
                .append("staffCount", getStaffCount()).append("createBy", getCreateBy())
                .append("createTime", getCreateTime()).append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime()).append("deleteFlag", getDeleteFlag())
                .append("orgCode", getOrgCode()).toString();
    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BpJob == false)
            return false;
        if (this == obj)
            return true;
        BpJob other = (BpJob) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
